package com.panda.admin.interfaces.log.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panda.admin.interfaces.log.service.SystemLogService;
import com.panda.admin.login.dto.LogDto;
import com.panda.admin.login.entity.SystemLog;
import com.panda.admin.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/7/11
 * description: 日志管理
 */
@Api(tags = "日志管理")
@RestController
@RequestMapping("/log")
public class SystemLogController {

    @Autowired
    SystemLogService systemLogService;

    @ApiOperation(value = "条件分页查询")
    @PostMapping("/pageList")
    public Result<Page<SystemLog>> pageList(@RequestBody LogDto logDto){
        return Result.success(systemLogService.pageList(logDto));
    }

    @ApiOperation(value = "删除记录")
    @PostMapping("/deleteLogs")
    public Result<Boolean> deleteLogs(@RequestBody List<Long> ids){
        return Result.success(systemLogService.deleteLogs(ids));
    }

    @ApiOperation(value = "保存记录")
    @PostMapping("/saveLogs")
    public Result<Boolean> saveLogs(@RequestBody SystemLog log){
        return Result.success(systemLogService.save(log));
    }

}
